<%--
  Created by IntelliJ IDEA.
  User: 86181
  Date: 2022/11/14
  Time: 9:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>动态库存查询</title>


</head>
<body>
        <div class="container" style="height:50%">
            <span style="color: steelblue"><strong>您正在做的业务是：库存管理--动态库存管理--动态库存查询</strong></span>
            <br>
            <strong><span>符合条件的产品总数量<span id="dynamicinventoryAmount"></span></span></strong><br>
            <span>当前库存总数：</span><span id="dynamicinventoryTotal"></span><span>列，</span>
            <span style="color: red">当前库存上限报警产品种类数：</span><span style="color: red" id="dynamicinventoryUpperLimit"></span><span style="color: red">列，</span>
            <span style="color: orange">库存下限报警产品种类数：</span><span style="color: orange" id="dynamicinventorylowerLimit"></span><span style="color: orange">列。</span>
            <table id="dynamicinventorytab">

            </table>
        </div>
        <!--查询所有入库的产品 和出库的模态框-->
        <div class="modal fade"  tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="dynamicinventorymodal">
            <div class="modal-dialog modal-lg">
                <div class="modal-content" id="dynamicinventorymodalson">

                </div>
            </div>
        </div>
        <script>

            $(function () {
                //表格添加数据
                $("#dynamicinventorytab").bootstrapTable({
                    url:"dynamicinventory.action",
                    method:'get',                      //请求方式（*）
                    contentType: "application/x-www-form-urlencoded", //如果用tomcat就要写这个
                    toolbar:"#toolbarfilestack ",//工具按件用那个容器
                    striped: true,//是否显示隔行变色
                    cache: false,//是否缓存
                    pagination: true,//是否显示分页
                    sortable: true,//是否显示排序
                    sortOrder: "aso",//排序方式
                    sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
                    pageNumber: 1,//初始化加载第一页，默认第一页,并记录
                    pageSize: 5,//每页记录数
                    pageList: [5, 10, 15, 20],//可供选择的每页的行数（*）
                    search: false,//是否显示输入框
                    strictSearch: true,
                    showColumns: true,//是否显示所有的列（选择显示的列）
                    showRefresh: true,//是否显示刷新按钮
                    minimumCountColumns: 2,//最少允许的列数
                    clickToSelect: true,//是否启用点击选中行
                    uniqueId: "menuid",//每一行的唯一标识，一般为主键列
                    showToggle: true,//是否显示详细视图和列表视图的切换按钮
                    cardView: false,//是否显示详细视图
                    detailView: false,//是否显示父子表
                    //获取查询到的参数
                    queryParams:function (params) {
                        var dynamicinventory={
                            pagesize:params.limit,
                            pageno:(params.offset/params.limit)+1,
                            sort:params.sort,
                            sortOrder:params.sort,
                        }
                        return dynamicinventory;
                    },
                    columns:[
                        {
                            field:"firstKindId",
                            title:"|级产品分类",
                            formatter:function (value,row,index) {
                                return "<span>"+row.firstKindId+row.firstKindName+"</span>"
                            }
                        },
                        {
                            field:"secondKindId",
                            title:"||级产品分类",
                            formatter:function (value,row,index) {
                                return "<span>"+row.secondKindId+row.secondKindName+"</span>"
                            }
                        },
                        {
                            field:"thirdKindId",
                            title:"|||级产品分类",
                            formatter:function (value,row,index) {
                                return "<span>"+row.thirdKindId+row.thirdKindName+"</span>"
                            }
                        },
                        {
                            field:"productId",
                            title:"产品编号/名称",
                            formatter:function (value,row,index) {
                                    return "<span>"+row.productId+"/"+row.productName+"</span>"
                            }
                        },
                        {
                            field:"amount",
                            title:"仓库数量",
                            formatter:function (value,row,index) {
                                return "<strong><a onclick='querybydynamicinventoryall("+row.productId+")' style='color:deepskyblue'>"+row.amount+"</a></strong>"
                            }
                        },
                        {
                            field:"maxCapacityAmount",
                            title:"最大存储量",
                        },
                        {
                            field:"maxAmount",
                            title:"安全库存上线",
                        },
                        {
                            field:"minAmount",
                            title:"安全库存下线",
                        }
                    ]
                })

                $(function () {

                    $.ajax({
                        url:"queryCellByDatels.action",
                        type:"post",
                        dataType:"json",
                        success:function (data) {

                            console.log(data)

                            //总数量
                            var num=0;

                            //下限
                            var lowerLimit=0;

                            //上限
                            var upperLimit=0;

                            $(data).each(function (index,item) {

                                num+=item.amount;

                                if(item.minamount>item.amount){
                                    lowerLimit++;
                                }

                                if(item.maxamount<item.amount){
                                    upperLimit++;
                                }

                            })

                            //总数量
                            $("#dynamicinventoryAmount").text(data.length);
                            //
                            $("#dynamicinventoryTotal").text(num);
                            $("#dynamicinventoryUpperLimit").text(upperLimit);
                            $("#dynamicinventorylowerLimit").text(lowerLimit);

                        }
                    })

                })

            })
            //查询入库出库明细
            function querybydynamicinventoryall(productId) {
              $("#dynamicinventorymodalson").load("dynamicinventorymodal.jsp",{"productId":productId})
              $("#dynamicinventorymodal").modal("show");
            }



        </script>
</body>
</html>
